@extends('admin.common.web')

@section('title','商品列表')

@section('style')
    <style>
    table{
        table-layout:fixed;/* 只有定义了表格的布局算法为fixed，下面td的定义才能起作用。 */
    }
    .ellipsis_line{
        width:100%;
        word-break:keep-all;/* 不换行 */
        white-space:nowrap;/* 不换行 */
        overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */
        text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/
    }

    .pageList {
        text-align: center;
        margin-top: 2%;
    }
    </style>
@endsection

@section('content')
    <!-- Page Breadcrumb -->
    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <a href="#">系统</a>
            </li>
            <li>商品列表</li>
        </ul>
    </div>
    <!-- /Page Breadcrumb -->

    <!-- Page Body -->
    <div class="page-body">
        @include('admin.common.msg')

        <button type="button" class="btn btn-sm btn-azure btn-addon" onClick="javascript:window.location.href = '{{ route('admin.goods.create') }}'">
            <i class="fa fa-plus"></i> 商品添加
        </button>
        <div class="row">
            <div class="col-lg-12 col-sm-12 col-xs-12">
                <div class="widget">
                    <div class="widget-body">
                        <div class="flip-scroll">
                            <div class="table-scrollable">
                            <table class="table table-bordered table-hover">
                                <thead class="">
                                <tr>
                                    <th class="text-center" width="4%">ID</th>
                                    <th class="text-center" width="5%">缩略图</th>
                                    <th class="text-center">名称</th>
                                    <th class="text-center" width="7%">分类</th>
                                    <th class="text-center" width="10%">品牌</th>
                                    <th class="text-center" width="6%">标价</th>
                                    <th class="text-center" width="5%">状态</th>
                                    <th class="text-center" width="5%">库存</th>
                                    <th class="text-center" width="4%">排序</th>
                                    <th class="text-center" width="14%">创建时间</th>
                                    <th class="text-center" width="20%">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($goodsList as $v)
                                <tr>
                                    <td align="center">{{ $v['id'] }}</td>
                                    <td align="center">
                                        @if($v['thumb'])
                                            <img src="{{ asset($v['thumb']) }}" width="40" height="40" alt=""/>
                                        @else
                                            暂无图片
                                        @endif
                                    </td>
                                    <td align="center" class="ellipsis_line" title="{{ $v['goods_name'] }}">{{ $v['goods_name'] }}</td>
                                    <td align="center" class="ellipsis_line" title="{{ $v['category']['category_name'] }}">{{ $v['category']['category_name'] }}</td>
                                    <td align="center" class="ellipsis_line" title="{{ $v['brand']['brand_name'] }}">{{ $v['brand']['brand_name'] }}</td>
                                    <td align="center">{{ $v['price'] }}</td>
                                    <td align="center">{{ $v['status'] == '0' ? '下架' : '上架' }}</td>
                                    <td align="center">{{ $v['inventory'] }}</td>
                                    <td align="center">{{ $v['sort'] }}</td>
                                    <td align="center" class="ellipsis_line" title="{{ $v['created_at'] }}">{{ $v['created_at'] }}</td>
                                    <td align="center">
                                        @if($v['kill_status'] == 1)
                                            <a href="{{ route('admin.goods.addToSecKill',['id'=>$v['id']]) }}" disabled class="btn btn-warning btn-sm shiny">
                                                秒杀中
                                            </a>
                                        @else
                                            <a href="{{ route('admin.goods.addToSecKill',['id'=>$v['id']]) }}" class="btn btn-warning btn-sm shiny">
                                                开启秒杀
                                            </a>
                                        @endif
                                        <a href="{{ route('admin.goods.edit',['id'=>$v['id']]) }}" class="btn btn-primary btn-sm shiny">
                                            <i class="fa fa-edit"></i> 编辑
                                        </a>
                                        <a href="{{ route('admin.goods.destroy',['id'=>$v['id']]) }}" onClick="alert('功能完善中'); return false;" class="btn btn-danger btn-sm shiny">
                                            <i class="fa fa-trash-o"></i> 删除
                                        </a>
                                    </td>
                                </tr>
                                @endforeach
                                </tbody>
                            </table>
                            </div>
                        </div>
                        <div>
                        </div>
                        <div class="pageList">
                            {{ $goodsList->links() }}
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
@endsection
